import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '@/views/login/index'
import Tabbar from '@/views/tabbar'
import Home from '@/views/home'
import Search from '@/views/search'
import SearchResult from '@/views/search-result'
import Article from '@/views/article'
import My from '@/views/my'

Vue.use(VueRouter)

const routes = [
  {
    path: '/login',
    component: Login
  },
  {
    name: 'article',
    path: '/article/:articleId',
    component: Article,
    props: true
  },
  {
    path: '/search',
    component: Search
  },
  {
    path: '/search/:q',
    component: SearchResult
  },
  {
    path: '/',
    component: Tabbar,
    children: [{
      path: '', // 默认子路由
      component: Home
    },
    {
      name: 'my',
      path: '/my', // 我的
      component: My
    }
    ]
  }
]

const router = new VueRouter({
  routes
})

export default router
